// 懒加载
const Home = () => import("@pages/Home");
const Search = () => import("@pages/Search");
const Login = () => import("@pages/Login");
const Register = () => import("@pages/Register");
const Detail = () => import("@pages/Detail");
const AddCartSuccess = () => import("@/pages/AddCartSuccess");
const ShopCart = () => import("@/pages/ShopCart");
const Pay = () => import("@pages/Pay");
const PaySuccess = () => import("@pages/PaySuccess");
const Trade = () => import("@pages/Trade");
const Center = () => import("@pages/Center");
const MyOrder = () => import("@pages/Center/components/MyOrder")
const TeamOrder = () => import("@pages/Center/components/TeamOrder")

export default  [
  {
    path: "/",
    redirect: "home",
  },
  {
    path: "/home",
    component: Home,
    name: "home",
  },
  {
    path: "/search/:keyword?",
    component: Search,
    name: "search",
  },
  {
    path: "/login",
    component: Login,
    name: "login",
    // 配置路由元信息 让footer隐藏
    meta: { isFooterHide: true },
  },
  {
    path: "/register",
    component: Register,
    name: "register",
    // 配置路由元信息 让footer隐藏
    meta: { isFooterHide: true },
  },
  {
    path: "/detail/:skuId",
    component: Detail,
    name: "detail",
  },
  {
    path: "/addcartsuccess",
    component: AddCartSuccess,
    name: "addcartsuccess",
    //路由独享守卫,针对当前路由的跳转是否允许
    beforeEnter(to, from, next) {
      if (sessionStorage.getItem("cartData")) {
        next();
      } else {
        next("/shopcart");
      }
    },
  },
  {
    path: "/shopcart",
    component: ShopCart,
    name: "shopcart",
  },
  {
    path: "/trade",
    component: Trade,
    name: "trade",
  },
  {
    path: "/center",
    component: Center,
    // name: "center",
    redirect:'/center/myorder',
    children:[
      {
        path:'myorder',
        component:MyOrder,
        name:'myorder'
      },
      {
        path:'teamorder',
        component:TeamOrder,
        name:'teamorder'
      }
    ]

  },
  {
    path: "/paysuccess",
    component: PaySuccess,
    name: "paysuccess",
  },
  {
    path: "/pay",
    component: Pay,
    name: "pay",
  },
]